/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.aptech.campaign.biz;

import com.aptech.campaign.dao.ManagementDAO;
import com.aptech.campaign.entities.Account;
import java.sql.Date;
import java.util.ArrayList;

/**
 *
 * @author Tai Nguyen
 */
public class ManagementBiz {

    ManagementDAO dao = new ManagementDAO();

    public ManagementBiz() {
    }

    /**
     * login to system
     * @param String userName, String password
     * @return the boolean value
     */
    public boolean login(String userName, String password) {
        return dao.login(userName, password);
    }

    /**
     * create a new account
     * @param Account acc
     * @return the boolean value
     */
    public boolean createAccount(Account acc) {
        return dao.createAccount(acc);
    }

    /**
     * change permission of user
     * @param String userName, int permisstionID, String permissionName
     * @return the boolean value
     */
    public boolean changePermission(String userName, int permissionID, String permissionName) {
        return dao.changePermission(userName, permissionID, permissionName);
    }

    /**
     * get permissionName
     * @param String userName
     * @return String PermissionName
     */
    public String findPermissionName(String userName) {
        return dao.readPermissionName(userName);
    }

    /**
     * change password
     * @param String userName, String oldPassword, String newPassword, String confirmNewPass
     * @return boolean value
     */
    public boolean storePassword(String userName, String oldPassword, String newPassword, String confirmNewPass) {
        return dao.updatePassword(userName, oldPassword, newPassword, confirmNewPass);
    }

    /**
     * change information of user
     * @param String userName
     * @return the boolean value
     */
    public boolean StoreProfile(String userName, String fullName, Date birthday, String phone, String gender) {
        return dao.updateProfile(userName, fullName, birthday, phone, gender);
    }

    /**
     * get array of information of account in database
     * @param
     * @return an Arraylist<>
     */
    public ArrayList<Account> findByAllAccount() {
        return dao.readByAllAccount();
    }

    /**
     * @return the lasterror
     */
    public String getLasterror() {
        return dao.getLasterror();
    }

    /**
     * @param lasterror the lasterror to set
     */
    public void setLasterror(String lasterror) {
        dao.setLasterror(lasterror);
    }
}
